<template>
  <view>
    <my-message-top :text="'萌猫相机'"></my-message-top>
    <view class="cat-camera-box">
      <text class="cat-camera-t1">tips:上传一张猫咪照片即可自动生成其他风格照片！</text>
      <image src="../../static/cat-camera/group148.png" mode="" @click="gotoStyle()"></image>
      <text class="cat-camera-t2">快来上传一张照片试试吧！</text>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        pic: ''
      };
    },
    methods:{
      async gotoStyle(){
        const res = await uni.chooseImage({
        	count: 1,
        	
        });
        console.log(res[1].tempFilePaths[0]);
        this.pic = res[1].tempFilePaths[0]
        const token = uni.getStorageSync('token')
        console.log(token);
        const data = await uni.uploadFile({
            url: 'http://www.newbabyya.com/utils/uploadImg',   
            filePath: this.pic,   
            name: 'file',   
            method: 'post',
            header:{
                   'Authorization': token
                  } 
        }); 
        console.log(JSON.parse(data[1].data).data);
        uni.navigateTo({
          url: '/subpkg/style-choice1/style-choice1?pic=' + JSON.parse(data[1].data).data
        })
      }
    }
  }
</script>

<style lang="scss">
.cat-camera-box{
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  margin: 225rpx 50rpx;
  .cat-camera-t1{
    font-size: 13px;
    color: #868686;
    margin-bottom: 45rpx;
  }
  image{
    width: 442rpx;
    height: 442rpx;
    margin-bottom: 50rpx;
  }
  .cat-camera-t2{
    font-size: 20px;
    font-weight: bold;
    color: #868686;
  }
}
</style>
